package testReflection;

import java.util.*;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:
 * User:Mr.Du
 * Date:2020/8/9
 * Time:16:46
 */
public class Solution {

    public static int[] twoSum(int[] arr, int target) {
        Map<Integer,Integer> mp = new HashMap<>();
        for(int i = 0;i < arr.length;i++){
            mp.put(arr[i],i);
        }
        System.out.println(mp);
        for(int i = 0;i<arr.length;i++){
            if(mp.containsKey(target - arr[i])){
                return new int[]{i,mp.get(target - arr[i])};
            }
        }
        return new int[]{-1,-1};
    }

    public static void main(String[] args) {
        int[] arr = {3,2,4};
        int target = 6;
        System.out.println(Arrays.toString(twoSum(arr,target)));
        Queue queue = new LinkedList();
        for(int i = 0;i<5;i++){
            System.out.println(queue.add(i));
        }
        int o = (int) ((LinkedList) queue).pollLast();
        System.out.println(queue.size());
        System.out.println(o);

    }
}
